import type { User,CodeType,UserInfo,Patient } from '@/types/user'
import { request } from '@/utils/request'

// 密码登录
export const loginByPassword = (mobile: string, password: string) =>
  request<User>('/login/password', 'POST', { mobile, password })
// 发送验证码
export const sendMobileCode=(mobile:string,type:CodeType)=>
  request<CodeType>('/code','GET',{mobile,type})

// 短信登录
export const loginByMobile = (mobile:string,code:string)=>
  request<User>('/login','POST',{mobile,code})
// 获取用户信息
export const getUserInfo=()=>request<UserInfo>('/patient/myUser')
// 获取家庭档案
export const getPatient=()=>request<Patient[]>('/patient/mylist')
// 添加患者
export const addPatient=(Patient:Patient)=>request<{id:string}>('/patient/add','POST',Patient)
// 编辑患者
export const editPatient=(Patient:Patient)=>request<{id:string}>('/patient/update','PUT',Patient)
// 删除患者
export const delPatient=(id:string)=>request(`/patient/del/${id}`,'DELETE')
// 获取患者信息
export const getPatientInformation=(id:string)=>request<Patient>(`/patient/info/${id}`)
// qq登录
export const loginByQQ = (openId: string) =>
  request<User>('/login/thirdparty', 'POST', { openId, source: 'qq' })

